/**
 * 超级管理员操作日志实体类
 *
 * 开发人员：徐少洋
 * 开发时间：2025-11-21
 * 模块职责：记录超级管理员的所有操作，确保系统安全和可追溯性
 */
package com.pbl.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

import javax.persistence.*;
import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "super_admin_logs")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class SuperAdminLog {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "super_admin_id", nullable = false)
    private SuperAdmin superAdmin;

    @Column(nullable = false, length = 64)
    private String action; // CREATE_ENTERPRISE, UPDATE_ENTERPRISE, DELETE_ENTERPRISE, VIEW_DATA, etc.

    @Column(name = "target_type", length = 32)
    private String targetType; // enterprise, user, system

    @Column(name = "target_id")
    private Long targetId;

    @Column(columnDefinition = "TEXT")
    private String detail; // JSON格式的详细信息

    @Column(name = "ip_address", length = 45)
    private String ipAddress;

    @Column(name = "user_agent", length = 255)
    private String userAgent;

    @Column(name = "created_at", insertable = false, updatable = false)
    private LocalDateTime createdAt;
}

